#ifndef POMODOROTIMER_H
#define POMODOROTIMER_H

#include <QMainWindow>
#include <QTimer>
#include <QSystemTrayIcon>
#include <QMap>

QT_BEGIN_NAMESPACE
namespace Ui { class PomodoroTimer; }
QT_END_NAMESPACE

class PomodoroTimer : public QMainWindow
{
    Q_OBJECT

public:
    PomodoroTimer(QWidget *parent = nullptr);
    ~PomodoroTimer();

private slots:
    void onStartStopClicked();
protected:
    void closeEvent(QCloseEvent *event) override;  // 添加关闭事件处理
private:
    Ui::PomodoroTimer *ui;
    bool m_forceQuit = false;  // 新增退出标志

    // 新增以下内容
    enum Phase { Work, ShortBreak, LongBreak };
    QTimer *timer;
    int remaining;
    Phase currentPhase;
    int totalTomatoes = 0;
    int totalMinutes = 0;
    int completedCycles = 0;
    QMap<QDate, int> dailyData;
    QSystemTrayIcon *trayIcon;

    void setupUI();
    void setupTrayIcon();
    void showNotification(const QString &message);
    void startCycle();
    void workPhase();
    void shortBreak();
    void longBreak();
    void updateTimer();
    void handlePhaseEnd();
    void saveDailyData();
    void loadData();
    void updateDisplay();
};

#endif // POMODOROTIMER_H
